# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


a = 'Hello', 'LWL'
b = 'Hello''LWL'
# 注意字串符a与b的区别，如果有逗号，
# 那么输出时将会是两个字串符一起输出，如
# 果没有输出将会两个字串符相互结合输出

c, d = 'Hello', 'LWL'


def print_hi(name):
    print(123)


def stringPractice1():
    name = "传智播客"
    stock_price = 19.99
    stock_code = "003032"
    stock_price_daily_growth_factor = 1.2
    growth_day = 7
    print(f"公司:{name},股票代码:{stock_code},当前股价:{stock_price}")
    print("每日增长系数是:%.1f, 经过%d天的增长后, 股价达到了%.2f" % (
        stock_price_daily_growth_factor, growth_day, stock_price * stock_price_daily_growth_factor ** growth_day))


# p28-数据输入(input)
def inputTest():
    name = input("请输入你的名字！")
    print("name:", name)


# p29 布尔类型
def booleanTest():
    true = (1 == 1)
    false = (1 != 1)
    print(type(true))
    print(type(false))


def testReturn():
    return True


# p30 if语句的基本格式
def testIf():
    age = 18
    if age <= 30:
        print("123")


# p31 p28-p30练习题
def p31Test():
    print("欢迎来到游乐园，儿童免费，成人收费!")
    age = int(input("请输入你的年龄："))
    if age >= 18:
        print("已成年，需收费")
    else:
        print("免费")


# p32 if else 组合判断语句
def testIfElse():
    print("p31有用到")


# 33 我要买票吗案例
def p33BuyTicket():
    print("欢迎来到黑马动物园")
    height = input("请输入您的身高(cm)")
    if int(height) > 120:
        print("身高到达120cm,需要10元购票")
    else:
        print("身高到达120cm,可以免费游玩")
    print("祝您游玩愉快")


def p34Test():
    print("欢迎来到黑马动物园")
    height = input("请输入您的身高(cm):")
    vip_level = input("请输入您的vip级别(1~5):")
    if int(height) < 120:
        print("身高未到达120cm,可以免费游玩")
    elif int(vip_level) > 3:
        print("您是vip3，可以免费游玩")
    else:
        print("您所有条件都不满足，需购票10元")
    print("祝您游玩愉快")


def p35Test():
    answer = 10
    if int(input("请输入第一次猜想的数字:")) == answer:
        print("猜对了")
    elif int(input("不对，再才一次:")) == answer:
        print("猜对了")
    elif int(input("不对，再猜最后一次:")) == answer:
        print("猜对了")
    else:
        print("Sorry, 全部猜错了，我想的是", answer)


import random


# p37Test
def p37Test():
    random_number = random.randint(1, 10)
    answer = int(input("猜猜是数字几？(1~10):"))
    if answer == random_number:
        print("猜中")
    elif answer > random_number:
        print("大了")
    else:
        print("小了")
    answer = int(input("第二次机会(1~10):"))
    if answer == random_number:
        print("猜中")
    elif answer > random_number:
        print("大了")
    else:
        print("小了")

    answer = int(input("第三次机会(1~10):"))
    if answer == random_number:
        print("猜中")
    elif answer > random_number:
        print("大了")
    else:
        print("小了")


def p42Test():
    j = 1
    while j < 10:
        i = 1
        while i <= j:
            print(f"{i} * {j} = {i * j}\t", end="")
            i = i + 1
        j = j + 1
        # print()


def p44Test():
    count = 0
    for char in "itheima is a brand of itcast":
        if char == "a":
            count += 1
    print(f"count:{count}\t", end="")


def p45Test():
    count = 0
    for i in range(2, 100, 2):
        count += 1
    print(count)


def p46Test():
    i = 11
    for i in range(5):
        print(i)
    print(i)


def p48Test():
    for i in range(1, 10):
        for j in range(1, i + 1):
            print(f"{j} * {i} = {j * i}\t", end="")
        print()


def p50Test():
    sumSalary = 10000
    for i in range(1, 21):
        if sumSalary <= 0:
            print("工资发完了，下个月领取吧")
            break
        performance = random.randint(1, 10)
        if performance < 5:
            print(f"员工{i}, 绩效分{performance}, 低于5, 不发工资， 下一位")
            continue
        sumSalary -= 1000
        print(f"向员工{i}发放工资1000元,账户余额还剩余{sumSalary}元")


def p55Test(temperature):
    if temperature > 37.5:
        print(f"您的体温是{temperature}, 需要隔离")
    else:
        print(f"您的体温是{temperature}, 体温正常请进!")


def p57Test():
    print("good")


def p58Test(a, b, c):
    print("p58测试函数")
    return a + b + c


def p61Test():
    print("----------主菜单----------")
    print("周杰伦，你好，欢迎来到银行ATM，请选择你的操作")
    print("查询余额\t输入[1]")
    print("存款\t\t输入[2]")
    print("取款\t\t输入[3]")
    print("退出\t\t输入[4]")
    balance = 0
    while True:
        result = int(input("请输入您的选择:"))
        if result == 1:
            print(f"周杰伦，您好，您的余额剩余{balance}元")
        elif result == 2:
            money = int(input("您要存多少钱？："))
            balance = deposit(balance, money)
            print(f"周杰伦，您好，您的余额剩余{balance}元")
        elif result == 3:
            money = int(input("您要取多少钱？："))
            balance = withdrawal(balance, money)
            print(f"周杰伦，您好，您的余额剩余{balance}元")
        elif result == 4:
            break
        else:
            print("不存在此选项，请重新输入")


def deposit(balance, money):
    return balance + money


def withdrawal(balance, money):
    return balance - money


def p65Test():
    test_list = ["good", "bad", "sad"]
    print(test_list.index("bad"))
    print(test_list.count("good"))
    test_list.append("1")
    print(test_list)


def p66Test():
    test_list = [21, 25, 21, 23, 22, 20]
    test_list.append(31)
    print(test_list)
    test_list.extend([29, 33, 30])
    print(test_list)
    first_age = test_list.pop(0)
    print(first_age)
    last_age = test_list.pop(-1)
    print(last_age)
    print(test_list.index(31))


def p67Test():
    test_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    result_list = list()
    for i in test_list:
        if i % 2 == 0:
            result_list.append(i)


def p68Test():
    test_tuple = ('周杰伦', 11, ['football', 'music'])
    print(test_tuple.index(11))
    print(test_tuple[0])
    del test_tuple[2][0]
    print(test_tuple)
    test_tuple[2].append('coding')
    print(test_tuple)


def p69Test():
    test_str = "itheima itcast boxuegu"
    print(test_str.count("it"))
    new_str = test_str.replace(" ", "|")
    print(new_str)
    print(new_str.split("|"))


def p71Test():
    test_list = [1, 2, 3, 4]
    test_sequence_list = test_list[3:0:-1]
    print(test_sequence_list)


def p72Test():
    test_str = '万过月薪，员序程马黑来，nohtyP学'
    print(test_str.split("，")[1][0:5:1][::-1])


def p74Test():
    test_list = ['黑马程序员', '传智播客', '黑马程序员', '传智播客', 'itheima', 'itcast', 'itheima', 'itcast', 'best']
    test_empty_set = set()
    for i in test_list:
        test_empty_set.add(i)
    print(test_empty_set)


def p75Test():
    test_dict = {"123": 123}
    print(test_dict["123"])


if __name__ == '__main__':
    # stringPractice1()
    # inputTest()
    # booleanTest()
    #     testIf()
    #     p31Test()
    # testIfElse()
    # p33BuyTicket()
    # p34Test()
    # p35Test()
    # p42Test()
    # p44Test()
    # p45Test()
    # p46Test()
    # p48Test()
    # p50Test()
    # p55Test(36.7)
    # print(p58Test(1, 2, 3))
    # p65Test()
    # p66Test()
    # p67Test()
    # p68Test()
    # p69Test()
    # p71Test()
    # p72Test()
    # p74Test()
    p75Test()
